Skip to content

Conversation

@s1gr1d
Copy link
Member

@s1gr1d s1gr1d commented Oct 28, 2025

This removes the automatic truncation of the span description. Now, all cache keys are set in the description.

part of #17389

@s1gr1d s1gr1d added the Integration: redis Issues related to Redis support for the Sentry Node SDK label Oct 28, 2025
Comment on lines 34 to 50
describe('early returns', () => {
it.each([
{ desc: 'no args', cmd: 'get', args: [], response: 'test' },
{ desc: 'unsupported command', cmd: 'exists', args: ['key'], response: 'test' },
{ desc: 'no cache prefixes', cmd: 'get', args: ['key'], response: 'test', options: {} },
{ desc: 'non-matching prefix', cmd: 'get', args: ['key'], response: 'test', options: { cachePrefixes: ['c'] } },
])('should always set sentry.origin but return early when $desc', ({ cmd, args, response, options = {} }) => {
vi.clearAllMocks();
Object.assign(_redisOptions, options);

cacheResponseHook(mockSpan, cmd, args, response);

expect(mockSpan.setAttribute).toHaveBeenCalledWith('sentry.origin', 'auto.db.otel.redis');
expect(mockSpan.setAttributes).not.toHaveBeenCalled();
expect(mockSpan.updateName).not.toHaveBeenCalled();
});
});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some general tests for the handler, as there were none for this behavior so far.

cursor[bot]

This comment was marked as outdated.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 28, 2025

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 9,009 - 8,797 +2%
GET With Sentry 1,378 15% 1,360 +1%
GET With Sentry (error only) 6,169 68% 6,159 +0%
POST Baseline 1,215 - 1,199 +1%
POST With Sentry 515 42% 504 +2%
POST With Sentry (error only) 1,075 88% 1,049 +2%
MYSQL Baseline 3,376 - 3,257 +4%
MYSQL With Sentry 480 14% 451 +6%
MYSQL With Sentry (error only) 2,793 83% 2,654 +5%

View base workflow run

@s1gr1d s1gr1d requested review from JPeer264 and chargome November 4, 2025 12:40
{ desc: 'no cache prefixes', cmd: 'get', args: ['key'], response: 'test', options: {} },
{ desc: 'non-matching prefix', cmd: 'get', args: ['key'], response: 'test', options: { cachePrefixes: ['c'] } },
])('should always set sentry.origin but return early when $desc', ({ cmd, args, response, options = {} }) => {
vi.clearAllMocks();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super-l: Maybe it is more future proof to move this into the afterEach

@s1gr1d s1gr1d enabled auto-merge (squash) November 6, 2025 09:37
Copy link
Member

@chargome chargome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a comment, other than that looks good!

span.updateName(truncate(spanDescription, 1024));
span.updateName(
_redisOptions.maxCacheKeyLength ? truncate(spanDescription, _redisOptions.maxCacheKeyLength) : spanDescription,
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a new comment here since the previous one was marked as outdated. Setting maxCacheKeyLength to 0 will result in not truncating at all, which would be unexpected IMO.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the default behavior of our truncate function and I didn't want to do it different here. I will add a note in the JS doc of the Redis instrumentation to make it clear what passing 0 does here.

@s1gr1d s1gr1d merged commit 7019263 into develop Nov 10, 2025
135 checks passed
@s1gr1d s1gr1d deleted the sig/truncation-redis branch November 10, 2025 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Integration: redis Issues related to Redis support for the Sentry Node SDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants